#pragma once

#include "comm_def.h"
#include "CPUIntensiveThread.h"


#include <thread>
#include <memory>
#include <vector>

class WebBaseInterface;

class ProcManager : public std::enable_shared_from_this<ProcManager>
{
public:
	ProcManager();
	virtual ~ProcManager();
	void InitProcManager(WebBaseInterface* pGateWay, unsigned int cpuTCount = 4);

	void StartProcManager();
	
	
	void IOIntensiveProcThread();	//io密集型处理(使用协程 boost fiber)
	void DispatchClientMessage(std::shared_ptr<SessionRequestMessage> msg);
	void DispathCpuIntensiveMessage(std::shared_ptr<SessionRequestMessage> msg);
	void DispatchIoIntensiveMessage(std::shared_ptr<SessionRequestMessage> msg);

private:
	std::vector<std::shared_ptr<CPUIntensiveThread>> _cpuThreads;
	std::shared_ptr<std::thread> _ioThread;
	unsigned int	_threadSelectIndex = 0;
	unsigned int	_threadMaxSize = 0;
	WebBaseInterface* _webGateWayInterface = nullptr;
};

